<template>
  <div class="dashboard-container">
    <el-button type="primary" @click="changeLang('en')">英文</el-button>
    <el-button type="warning" @click="changeLang('zh')">中文</el-button>
    <el-table :data="data">
      <el-table-column label="测试" prop="abc" />
    </el-table>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import i18n from '@/lang'
import Cookie from 'js-cookie' // 引入cookie包 把用户选的语言存起来
console.log(i18n)
export default {
  name: 'Dashboard',
  components: {

  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  data() {
    return {
      data: []
    }
  },
  methods: {
    changeLang(locale) {
      i18n.locale = locale
      // 同步到cookie当中 持久化
      Cookie.set('language', locale)
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
